<div style="padding-left:8px;">
    {{ accounts.links('pagination.bootstrap-4')|raw }}
</div>
<table class="table table-responsive table-hover" id="sortable-table">
    <thead>
    <tr>
        <th class="hidden-sm hidden-xs">&nbsp;</th>
        <th>{{ trans('list.name') }}</th>
        {% if objectType == 'asset' %}
            <th class="hidden-sm hidden-xs hidden-md">{{ trans('list.role') }}</th>
        {% endif %}
        {% if objectType == 'liabilities' %}
            <th>{{ trans('list.liability_type') }}</th>
            <th>{{ trans('form.liability_direction') }}</th>
            <th>{{ trans('list.interest') }} ({{ trans('list.interest_period') }})</th>
        {% endif %}
        <th class="hidden-sm hidden-xs">{{ trans('form.account_number') }}</th>
        {% if objectType != 'liabilities' %}
            <th style="text-align: right;">{{ trans('list.currentBalance') }}</th>
        {% endif %}
        {% if objectType == 'liabilities' %}
            <th style="text-align: right;">
                {{ trans('firefly.left_in_debt') }}
            </th>
        {% endif %}
        <th class="hidden-sm hidden-xs">{{ trans('list.active') }}</th>
        {# hide last activity to make room for other stuff #}
        {% if objectType != 'liabilities' %}
            <th class="hidden-sm hidden-xs hidden-md">{{ trans('list.lastActivity') }}</th>
        {% endif %}
        <th style="width:15%;"
            class="hidden-sm hidden-xs hidden-md">{{ trans('list.balanceDiff') }}</th>
        <th class="hidden-sm hidden-xs">&nbsp;</th>
    </tr>
    </thead>
    <tbody>
    {% for account in accounts %}
        <tr class="sortable-object" data-id="{{ account.id }}" data-order="{{ account.order }}" data-position="{{ loop.index0 }}">
            <td class="hidden-sm hidden-xs">
                <span class="fa fa-fw fa-bars object-handle"></span>
            </td>
            <td>
                <a href="{{ route('accounts.show',account.id) }}">{{ account.name }}</a>
                {% if account.location %}
                    <span class="fa fa-fw fa-map-marker"></span>
                {% endif %}
                {% if account.attachments.count() > 0 %}
                    <span class="fa fa-fw fa-paperclip"></span>
                {% endif %}
            </td>
            {% if objectType == "asset" %}
                <td class="hidden-sm hidden-xs hidden-md">
                    {% for entry in account.accountmeta %}
                        {% if entry.name == 'account_role' %}
                            {{ ('account_role_'~entry.data)|_ }}
                        {% endif %}
                    {% endfor %}
                </td>
            {% endif %}
            {% if objectType == 'liabilities' %}
            <td>{{ account.accountTypeString }}</td>
            <td>{{ trans('firefly.liability_direction_'~account.liability_direction~'_short')  }}</td>
            <td>{{ account.interest }}% ({{ account.interestPeriod|lower }})</td>
            {% endif %}
            <td class="hidden-sm hidden-xs">{{ account.iban }}{% if account.iban == '' %}{{ accountGetMetaField(account, 'account_number') }}{% endif %}</td>
            {% if objectType != 'liabilities' %}
            <td style="text-align: right;">
                <span style="margin-right:5px;">
                {{ formatAmountByAccount(account, account.endBalance) }}
                </span>
            </td>
            {% endif %}
            {% if objectType == 'liabilities' %}
            <td style="text-align: right;">
                {% if '-' != account.current_debt %}
                    <span class="text-info money-transfer">{{ formatAmountByAccount(account, account.current_debt, false) }}</span>
                {% endif %}
            </td>
            {% endif %}
            <td class="hidden-sm hidden-xs">
                {% if account.active %}
                    <span class="fa fa-fw fa-check"></span>
                {% else %}
                    <span class="fa fa-fw fa-ban"></span>
                {% endif %}
            </td>
            {# hide last activity to make room for other stuff #}
            {% if objectType != 'liabilities' %}
                {% if account.lastActivityDate %}
                    <td class="hidden-sm hidden-xs hidden-md">
                        <!-- {{ account.lastActivityDate }} -->
                        {{ account.lastActivityDate.isoFormat(monthAndDayFormat) }}
                    </td>
                {% else %}
                    <td class="hidden-sm hidden-xs hidden-md">
                        <em>{{ 'never'|_ }}</em>
                    </td>
                {% endif %}
            {% endif %}
            <td class="hidden-sm hidden-xs hidden-md" style="text-align: right;">
                <span style="margin-right:5px;">
                    {{ formatAmountByAccount(account, account.difference) }}
                </span>
            </td>
            <td class="hidden-sm hidden-xs">
                <div class="btn-group btn-group-xs pull-right">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        {{ 'actions'|_ }} <span class="caret"></span></button>
                    <ul class="dropdown-menu dropdown-menu-right" role="menu">
                        <li><a href="{{ route('accounts.edit',account.id) }}"><span class="fa fa-fw fa-pencil"></span> {{ 'edit'|_ }}</a></li>
                        <li><a href="{{ route('accounts.delete',account.id) }}"><span class="fa fa-fw fa-trash"></span> {{ 'delete'|_ }}</a></li>
                        {% if objectType == 'asset' %}
                        <li><a href="{{ route('accounts.reconcile',account.id) }}"><span class="fa fa-fw fa-check"></span> {{ 'reconcile_this_account'|_ }}</a></li>
                        {% endif %}
                    </ul>
                </div>
            </td>
        </tr>

    {% endfor %}
    </tbody>
</table>
<div style="padding-left:8px;">
    {{ accounts.links('pagination.bootstrap-4')|raw }}
</div>
